home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Mar 14, 1997
- // Author: laf
- //
- // Description:
- // This script runs rebuild surface on the selection list.
- //
-
-
- global proc performRebuildSurfaceSet( int $doHistory, int $replaceOriginal,
- int $rebuildType, float $globalTol,
- int $srfNumSpansU, int $srfNumSpansV,
- int $srfDegreeU, int $srfDegreeV,
- int $endKnots,
- int $keepParmRange, int $keepCornerPts,
- int $keepControlPoints, int $direction,
- int $srfUseGlobalTol, float $srfLocalTol,
- int $polys )
- {
- // Get a list of each type of acceptable object type -
- // surfaces, and surfaces-on-surface.
- //
- global int $gSelectNurbsSurfacesBit;
- global int $gSelectSubdivSurface;
- global int $gSelectIsoparmsBit;
- global int $gSelectMeshesBit;
- string $surfaceList[] =`filterExpand -ex true -sm $gSelectNurbsSurfacesBit`;
- string $isoparmList[] = `filterExpand -ex true -sm $gSelectIsoparmsBit`;
-
- if( $rebuildType == 2 ) {
- if( (size($surfaceList) + size($isoparmList)) < 2 ) {
- error( "Select at least two NURBS surfaces/isoparms to " +
- "rebuild with match knots option.") ;
- return;
- }
- }
- else {
- if( (size($surfaceList) + size($isoparmList)) < 1 ) {
- error( "Nothing was selected to rebuild. You must select " +
- "NURBS surfaces or surface isoparms.");
- return;
- }
- }
-
- // Put together the command to execute
- //
- $cmd = "rebuildSurface" + " -ch " + $doHistory +
- " -rpo " + $replaceOriginal+
- " -rt " + $rebuildType +
- " -end " + $endKnots +
- " -kr " + $keepParmRange +
- " -kcp " + $keepControlPoints +
- " -kc " + $keepCornerPts;
-
- $cmd += " -su " + $srfNumSpansU + " -du " + $srfDegreeU;
- $cmd += " -sv " + $srfNumSpansV + " -dv " + $srfDegreeV;
-
- if( $srfUseGlobalTol == 0 ) { // Use globl tolerance vs. local tolerance
- $cmd += " -tol " + $srfLocalTol;
- } else {
- $cmd += " -tol " + $globalTol;
- }
- if( $polys ) {
- $cmd += " -po " + $polys;
- }
- $cmd += " ";
-
- // Execute the command on all surfaces
- //
- int $i;
- string $isoCmd; $isoCmd = $cmd;
- $cmd = $cmd + " -dir " + $direction ;
- string $surfaceResults[] ;
- if( $rebuildType == 2 ) {
- int $l = size($surfaceList) ;
- if( $l > 2 ) {
- warning( "Rebuilding all but the last surface to match knots " +
- "of the last surface in the selection list" );
- }
- if( $l >= 2 ) {
- int $nitems = 2 ;
- $cmd = appendToCmdPlaceHoldersForSelectionItems( $cmd, $nitems ) ;
- string $srfPair[2] ;
- for( $i=0; $i<($l-1); $i+=1 ) {
- $srfPair[0] = $surfaceList[$i] ;
- $srfPair[1] = $surfaceList[$l-1] ;
- string $oneRes[] = executeCmdOnItems($cmd,$srfPair);
- appendStringArray( $surfaceResults, $oneRes, size($oneRes) );
- }
- }
- } else {
- $surfaceCmd = $cmd + " %s;";
- $surfaceResults = executeForEachObject( $surfaceList, $surfaceCmd );
- }
-
- // Processing isoparms is a little more involved. Use groupObjectsByName().
- // This chunk of code groups the isoparms from the selection list
- // and uses them to guess a rebuild direction. If an isoparm is
- // selected in both directions on the same surface, then this
- // will figure out that the user wants to rebuild in BOTH directions.
- // Even if the user has selected >1 U isoparms on the same surface,
- // this will only call the rebuild command ONCE.
- //
- string $isoparmResults[];
- string $isoparms[] = groupObjectsByName( $isoparmList, "." );
- int $numIsoStrs = size($isoparms);
- for( $i = 0; $i < $numIsoStrs; $i ++ ) {
-
- string $rebuildCmd;
- string $results[];
- string $objectName[];
- string $names[];
-
- tokenize $isoparms[$i] " " $objectName;
- $names = groupObjectsByName( $objectName, "\\[" );
-
- if( size($names) > 1 ) {
- tokenize $isoparms[$i] "\\." $objectName;
- $rebuildCmd = $isoCmd + " -dir 2 " + $objectName[0];
- }
- else {
- string $foundU = `match "\\.u\\[" $names[0]`;
- if( size($foundU) > 0 ) {
- tokenize $isoparms[$i] "\\." $objectName;
- $rebuildCmd = $isoCmd + " -dir 1 " + $objectName[0];
- }
- else {
- string $foundV = `match "\\.v\\[" $names[0]`;
- if( size($foundV) > 0 ) {
- tokenize $isoparms[$i] "\\." $objectName;
- $rebuildCmd = $isoCmd + " -dir 0 " + $objectName[0];
- }
- }
- }
-
- if( catch( $results = evalEcho( $rebuildCmd )) ) {
- warning( "Problem executing rebuild command: " + $rebuildCmd);
- }
- else {
- int $j;
- int $numResults = size( $results );
- int $numIsoResults = size( $isoparmResults );
- for( $j = 0; $j < $numResults; $j ++, $numIsoResults ++ ) {
- $isoparmResults[$numIsoResults] = $results[$j];
- }
- }
- }
-
- if( (size($surfaceResults)+size($isoparmResults)) == 0 ) {
- int $l = size($surfaceList) ;
- if( $rebuildType == 2 ) {
- if( $l < 2 ) {
- error( "Select at least two NURBS surfaces to " +
- "rebuild with match knots option.") ;
- }
- else {
- error("Rebuild surface failed on the current valid selection.");
- }
- }
- else if( 0 == $l ) {
- error( "Nothing was selected to rebuild. You must select " +
- "NURBS surfaces or surface isoparms.");
- }
- else {
- error( "Rebuild surface failed on the current valid selection." );
- }
- } else {
- // Select all the results with one select command. Note that only
- // resulting surfaces and surfaces are selected, not dependency nodes.
- //
- string $selectString;
- $selectString = "select ";
- int $i;
- $surfaceResults = `filterExpand -ex true -sm $gSelectNurbsSurfacesBit -sm $gSelectSubdivSurface -sm $gSelectMeshesBit $surfaceResults`;
- int $numSurfaces = size($surfaceResults);
- for( $i = 0; $i < $numSurfaces; $i ++ ) {
- $selectString += $surfaceResults[$i];
- $selectString += " ";
- }
- $isoparmResults = `filterExpand -ex true -sm $gSelectNurbsSurfacesBit -sm $gSelectSubdivSurface -sm $gSelectMeshesBit $isoparmResults`;
- int $numSurfaces = size($isoparmResults);
- for( $i = 0; $i < $numSurfaces; $i ++ ) {
- $selectString += $isoparmResults[$i];
- $selectString += " ";
- }
- $selectString += ";";
- select -cl;
- eval($selectString);
- }
- }
-
-